<%@ page import="com.wuchao.service.serviceImpl.ServiceImpl" %>
<%@ page import="com.wuchao.entity.User" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Root404
  Date: 2022/7/7
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="f" uri="http://mycompany.com" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1>欢迎来到主界面${f:show("xxxx")}</h1>
<table border="3">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>sex</th>
        <th>操作</th>
    </tr>
    <% ServiceImpl service = new ServiceImpl();
        int pageNum=1;
        int pageSize=2;
        if(request.getParameter("pageNum")!=null){
           pageNum=Integer.parseInt(request.getParameter("pageNum")) ;
        }
        int pageMax=1;
        if(request.getParameter("count")!=null){
            int count=Integer.parseInt(request.getParameter("count")) ;
            pageMax=count%pageSize==0?count/pageSize:count/pageSize+1;
        }
        List<User> list = service.findPoJo("select * from user limit ?,?",(pageNum-1)*pageSize,pageSize);
        for(User user : list){%>
    <tr>
        <td><%=user.getId()%></td>
        <td><%=user.getName()%></td>
        <td><%=user.getSex()%></td>
        <td>
            <a href="${pageContext.request.contextPath}/ServletUserController?op=delete&id=<%=user.getId()%>">点我删除</a>
            <a href="add.jsp">增加</a></td>
    </tr>
    <%  }
    %>
</table><a href="${pageContext.request.contextPath}/ServletUserController?op=page&pageNum=1">首页</a>
<a href="${pageContext.request.contextPath}/ServletUserController?op=page&pageNum=<%=pageNum-1<=1?1:pageNum-1%>" <%=pageNum<=1?"hidden":""%>>上一页</a>
<a href="${pageContext.request.contextPath}/ServletUserController?op=page&pageNum=<%=pageNum+1>=pageMax?pageMax:pageNum+1%>" <%=pageNum>=pageMax?"hidden":""%>>下一页</a>
<a href="${pageContext.request.contextPath}/ServletUserController?op=page&pageNum=<%=pageMax%>">尾页</a>
<span><%=request.getParameter("isdelete1")==null?"":"删除成功"%></span>
<span><%=request.getParameter("isdelete2")==null?"":"删除失败"%></span>
<%--<script>
    alert("我来搞事的")
</script>--%>
</body>
</html>
